package com.hdaccp.ch02

import org.apache.spark.sql.SparkSession

/**
  * 分析tomcat服务器日志
  */
object Demo3 {

  def main(args: Array[String]): Unit = {
    //1.
    val spark = SparkSession.builder()
      .appName("ch02Demo3App")
      .master("local[2]")
      .getOrCreate()

    //  import spark.implicits._

    val rdd = spark.sparkContext.textFile("f:/resources/localhost_access_log.2017-05-02.txt")

   // rdd.collect().foreach(println)
    val arr = rdd.map(a=>a.split(" ")).map(b=>b(6).split("/")(2)).collect()

  //  println(arr(6)) ;
  /*  for(x<- arr){
      print(x + "--") ;
    }*/


    spark.stop()
  }

  case class MyLog(address:String)

}
